<template>
  <div>
     <button v-if="!isLogin" @click="goLogin">立即登录</button>
     <button v-else @click="loginOut">退出登录</button>
 </div>
</template>

<script>
export default {
  name: '',
  data() { 
    return {
      isLogin: false
    }
  },
  created() {
    if(localStorage.getItem('token')) {
        this.isLogin = true
      } else {
        this.isLogin = false
      }
  },
  methods:{
      goLogin() {
        this.$router.push('/login')
        
      },

      loginOut() {
        this.$router.push('/')
        localStorage.removeItem('token')
      }
  },
 }
</script>

<style scoped>
</style>